// 初始化问题对象，生成新的surveyJson
export function generateSurveyJsonAndQuestionObject(surveyJson: any, surveyName: string) {
  if (!surveyJson) return {};

  const elements = [];
  const newObject = {};
  const newJson = { pages: [{ name: surveyName, title: surveyName, elements }] };

  surveyJson.pages.forEach((page) => {
    elements.push(...page.elements);

    page.elements?.forEach((element) => {
      if (element.type !== 'panel') {
        newObject[element.name] = element;
      }
      element.elements?.forEach((panel_element) => {
        newObject[panel_element.name] = panel_element;
      });
    });
  });

  return { newJson, newObject };
}

export default {};
